package org.qqcui.designpattern.patterns.memorandum.simple;

/**
 * 备忘录模式客户端
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/7 10:21
 **/
public class Client {

    public static void main(String[] args) {
        Originator originator = new Originator();
        CareTaker careTaker = new CareTaker();

        originator.setState("状态#1：攻击力100");
        careTaker.add(originator.saveStateMemento());

        originator.setState("状态#2：攻击力80");
        careTaker.add(originator.saveStateMemento());

        System.out.println("当前状态是：" + originator.getState());

        // 回复到状态#1
        originator.getStateFromMemento(careTaker.get(0));
        System.out.println("恢复到状态1后的状态为：" + originator.getState());
    }
}
